import WxRequest from "./Imps/WxRequest";
import WebRequest from "./Imps/WebRequest";
import {IS_FOR_WX} from "../AppConfig";

let _imp = null;
if (cc.sys.platform === cc.sys.WECHAT_GAME && IS_FOR_WX) {
  _imp = new WxRequest();
} else {
  _imp = new WebRequest();
}

export default class HttpRequest {
  static request(url, method = 'POST', data = null, options = null) {
    _imp.request(url, method, data, options);
  }

  static post(url, data = null, options = null) {
    _imp.post(url, data, options);
  }

  static postJson(url, data = null, options = null) {
    _imp.postJson(url, data, options);
  }

  static getJson(url, data, options = null) {
    _imp.getJson(url, data, options);
  }
}
